<template>
  <div class="panel" :id="object.id">
<!--    <el-link type="danger" :underline="false" class="update">编辑</el-link>-->
    <el-link class="title" @click="fullContent">{{ object.title }}</el-link>
    <!--        时间标题-->
    <div class="time">{{ object.time }}</div>
    <!--     内容和图片   -->
    <div class="text-img">
      <!--          正文-->
      <div class="content" :class="{part:objPart}">{{ object.content }}</div>
      <!--          图片s-->
      <ContentImg :content="object"  :part="objPart"></ContentImg>
    </div>
  </div>
</template>

<script>
import ContentImg from "@/components/content-img";
import {getDayList} from "@/util/request/content";

export default {
  name: "panel",
  components: {ContentImg},
  props: ['content', 'part'],
  data() {
    return {
      object: this.content,
      objPart: this.part
    }
  },
  beforeMount() {
    if (this.object === undefined) {
      this.objPart = false
      getDayList({id: this.$route.query.id})
          .then(res => {
            let data = res.data
            this.object = data[Object.keys(data)[0]][0]
          })
    }
  },
  methods: {
    fullContent() {
      const {href} = this.$router.resolve({
        name: `fullContent`,
        query: {
          id: this.object.id,
        }
      });
      window.open(href, '_blank')
    }
  }
}
</script>

<style scoped>
.panel {
  border-radius: 10px;
  box-shadow: 2px 2px 10px 2px lightgray;
  width: 100%;
  padding: 10px;
  margin: 30px auto;
  position: relative;
}

.update {
  position: absolute;
  right: 50px;
  top: 28px;
}

.title {
  font-size: 25px;
  font-weight: bold;
  margin-top: 10px;
}

.time {
  font-size: 12px;
  margin-top: 5px;
}

.text-img {
  margin-top: 10px;
  width: 100%;
}

.content {
  width: 1360px;
  margin: 10px auto;
  font-size: 18px;
}

.content.part {
  max-height: 200px;
  overflow: scroll;
  scrollbar-width: none;
}

.content::-webkit-scrollbar {
  display: none;
}

</style>